Skip to content

Properly handle non-approved revision deletions #6577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2025

Conversation

akatsoulas
Copy link
Collaborator

No description provided.

@akatsoulas akatsoulas requested review from Copilot and escattone and removed request for Copilot March 20, 2025 12:01
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the logic for handling deletions of non-approved user revisions by improving the filtering conditions and adding a comprehensive test to verify the behavior.

  • Updated deletion logic in the handlers to ensure that only the deleted user’s non-approved revisions are removed while preserving documents and revisions belonging to other users.
  • Added a new test case in kitsune/wiki/tests/test_handlers.py to validate the mixed revision deletion scenario.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
kitsune/wiki/tests/test_handlers.py Added a test case to ensure only the target user's non-approved revisions are deleted and documents with contributions from other users are preserved.
kitsune/wiki/handlers.py Updated the on_user_deletion method to refine deletion logic for non-approved revisions and improve contributor handling.

@escattone
Copy link
Contributor

escattone commented Mar 20, 2025

This doesn't fix mozilla/sumo#2262, because that one is due to cascade deletions via the based_on field. I'll create a PR to resolve that, but I can't finalize the PR until after this merges, since it'll depend on it.

@akatsoulas akatsoulas force-pushed the non-reviewed-revisions branch from 6c59397 to bc5c440 Compare March 21, 2025 10:07
@akatsoulas
Copy link
Collaborator Author

@escattone PR updated

Copy link
Contributor

@escattone escattone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @akatsoulas, I was wrong about revisions__is_approved=False being equivalent to current_revision__isnull=True. We need to use current_revision__isnull=True in order to ensure that all of the document's revisions are un-approved. Using revisions__is_approved=False only ensures that at least one is un-approved. Once that's changed, everything looks great.

@escattone
Copy link
Contributor

@akatsoulas I'll make the final tweak I suggested above and merge this.

@escattone escattone merged commit b2b7ce4 into mozilla:main Mar 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants